package org.tim.net;

import java.io.*;

/**
 * An InputStreamReader compatible with network input streams
 * @author Tim Fennis
 */
public class NetworkStreamReader {
	
	private InputStream _in = null;
	private BufferedReader _br = null;
	private boolean debug = false;
	
	/**
	 * Construct the class with an inpustream as parameter
	 */
	public NetworkStreamReader ( InputStream in ) {
		_in = in;
		_br = new BufferedReader ( new InputStreamReader ( _in ) );
	}
	
	/**
	 * Read one int (usualy a char) from the input stream
	 * @return The char
	 * @throws IOException just like read() in java.net.InputStream
	 */
	public int read ( ) throws IOException {
		return _in.read();
	}
	
	/**
	 * Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
	 * @return A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
	 */
	public String readLine ( )
		throws IOException {
		return _br.readLine();
	}

		
	/**
	 * Close the input stream
	 * @throws IOException if an I/O error occurs
	 */
	public void close() throws IOException {
		_br.close();
	}
}